#!/usr/bin/python
# -*- coding: UTF-8 -*-

from kpautos.engine.case import Case
from kptest.config.enum import DeviceType, HostType, DeviceUtility


class BMC_SSH_017(Case):
    """
        Name:
            BMC_SSH_017
        Label:
            CLI接口可以查询管理网口的IP
        PreCondition:
            1、BMC正常运行
        TestStep:
            1.登录BMC
            2.执行ipmcget -d ipinfo，有结果A）
        ExpectedResult:
            A）查看管理网口IP正确
        Parameters:

        Remark:

    """

    # 测试执行前配置等准备操作
    def pre_test_case(self):
        self.device_dut = self.resource.get_device(device_type=DeviceType.Server, utility=DeviceUtility.DUT)
        self.bmc_host = self.device_dut.get_host(host_type=HostType.BMC)
        self.bmc_ip = self.bmc_host.local_ip

    # 测试步骤
    def procedure(self):
        self.log_step(f"1、执行ipmcget -d ipinfo查看管理网口信息")
        resp = self.bmc_host.run({"command": [f"ipmcget -d ipinfo"], "timeout": 3})
        self.log_info(resp)
        if self.bmc_ip not in resp['stdout']:
            self.assertIsNotNone(None, f"查看管理网口信息有误：{resp['stdout']}")

    # 测试结束后恢复环境
    def post_test_case(self):
        pass